﻿<Window x:Class="_12.BindToList.ReferenceTemplate"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="Reference Shared Template" Height="300" Width="300">
    <Window.Resources>
        <Style TargetType="TextBlock" x:Key="subproperty">
            <Setter Property="Foreground" Value="Orange"/>
            <Setter Property="FontWeight" Value="Bold"/>
        </Style>
        <!--note: datatemplate can be also referenced by "staticresource + keyname"
        and it is not necessary to define the "datatype"
        only define the "datatype" when you want to add some strict constraints-->
        <DataTemplate x:Key="personLayout">
            <StackPanel Margin="3">
                <TextBlock Text="{Binding Path=Name}" Foreground="Navy" FontWeight="Black" FontSize="15"/>
                <TextBlock>
                    Title: <TextBlock Text="{Binding Path=Title}"  Style="{StaticResource subproperty}"/> 
                    Organization: <TextBlock Text="{Binding Path=Organization}" Style="{StaticResource subproperty}"/>
                </TextBlock>
            </StackPanel>
        </DataTemplate>
    </Window.Resources>
    <ListBox ItemsSource="{Binding}" ItemTemplate="{StaticResource personLayout}" />
</Window>
